package com.blockchain.console.servlets.content.cjwt;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.common.enums.QuestionType;
import com.blockchain.console.service.content.QuestionManage;
import com.blockchain.console.service.content.entity.QuestionRecord;
import com.blockchain.framework.http.servlet.annotation.Right;
import com.blockchain.framework.service.ServiceSession;
import com.blockchain.framework.service.query.Paging;
import com.blockchain.framework.service.query.PagingResult;
import com.blockchain.util.parser.EnumParser;
import com.blockchain.util.parser.IntegerParser;

@Right(id = "C_CONTENT_CJWT_QUESTIONLIST", isMenu=true, name = "帮助中心")
public class QuestionList extends AbstractQuestionServlet{

	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request,
			HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}
	
	@Override
	protected void processPost(final HttpServletRequest request,
			final HttpServletResponse response,
			final ServiceSession serviceSession) throws Throwable {
		QuestionManage questionManage=serviceSession.getService(QuestionManage.class);
		String question=request.getParameter("question");	
		QuestionType qt=EnumParser.parse(QuestionType.class,request.getParameter("qt"));
		PagingResult<QuestionRecord> pr=questionManage.search(question,qt, new Paging() {
			
			@Override
			public int getSize() {
				return 10;
			}
			
			@Override
			public int getCurrentPage() {
				 return IntegerParser.parse(request
						.getParameter(PAGING_CURRENT));
			}
		});
		request.setAttribute("pr", pr);
		forwardView(request, response, getClass());
	}
}
